import request from '@/utils/request'

const urls = {
  list: 'admin/dept/list',
  page: 'admin/dept/page',
  tree: 'admin/dept/tree',
  findDept: 'admin/dept/findDept'
}

export function getPage(params) {
  return request({
    url: urls.page,
    method: 'get',
    params
  })
}

export function getDepts(params) {
  return request({
    url: urls.list,
    method: 'get',
    params
  })
}

export function getTree(params) {
  return request({
    url: urls.tree,
    method: 'get',
    params
  })
}

export function getDeptsByType(params) {
  return request({
    url: urls.findDept,
    method: 'get',
    params
  })
}

export function add(data) {
  return request({
    url: 'admin/dept/save',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'admin/dept/del',
    method: 'post',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'admin/dept/save',
    method: 'post',
    data
  })
}

export function getCompanyList(params) {
  return request({
    url: 'admin/dept/getCompanyList',
    method: 'get',
    params
  })
}

export function getJoinProjectCompanyList(params) {
  return request({
    url: 'admin/dept/getJoinProjectCompanyList',
    method: 'get',
    params
  })
}

export function getCompanyListByProjectId(params) {
  return request({
    url: 'admin/dept/getCompanyListByProjectId?projectId=' + params,
    method: 'get',
  })
}

export function getRegionList(params) {
  return request({
    url: 'admin/dept/getRegionList',
    method: 'get',
    params
  })
}

export function getDataDepts(id) {
  return request.get('admin/dept/dataDept?id=' + id)
}


export function sectorCompany() {
  return request.get('admin/dept/sectorCompany')
}

export function getTypeCompanyUsers(data) {
  return request({
    url: 'admin/dept/getTypeCompanyUsers',
    method: 'post',
    data
  })
}
export function listForSys(data) {
  return request.get('admin/dept/listForSys?condition=' + data)
}
export function getOne(data) {
  return request.get('admin/dept/getOne?id=' + data)
}


export default {
  getCompanyListByProjectId,
  getJoinProjectCompanyList,
  getRegionList,
  getCompanyList,
  add,
  edit,
  del,
  getDepts,
  urls,
  getDataDepts,
  getTree,
  getDeptsByType,
  getPage,
  sectorCompany,
  getTypeCompanyUsers,
  listForSys,
  getOne
}

